<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
    <link rel="stylesheet" href="../assets/css/index.css"/>
</head>
<body>
<h1>实例方法</h1>
<hr>
<div id="app">
</div>
<p>
    <button onclick="xiezai()">卸载</button>
    <button onclick="shuaxin()">刷新</button>
    <button onclick="xiugai()">修改</button>
</p>

<script>
    var header = Vue.extend({
        template: '<p>{{message}}</p>',
        data: function () {
            return {
                message: 'hello my is header'
            }
        },
        updated:function () {
          console.log('更新')
        },
        destroyed: function () {
            console.log('卸载')
        }
    })
    var vm = new header().$mount('#app');

    function xiezai() {
        vm.$destroy();
    }
    function shuaxin() {
        vm.$forceUpdate();
    }
    function xiugai() {
        vm.message='数据被修改了'
        vm.$nextTick(function () {
            console.log('更新完了我被调用')
        })
    }
</script>
</body>
</html>